package com.example.demojimmer.domain.userauth.model.entity;

import org.babyfish.jimmer.sql.JoinTable;
import org.babyfish.jimmer.sql.ManyToMany;
import org.babyfish.jimmer.sql.MappedSuperclass;

import java.util.List;

/**
 * 保存关联关系映射
 * 角色表;
 *
 * @author : liuhailong
 * @date : 2024-7-10
 */
@MappedSuperclass
public interface StRoleMapping {


    /**
     * JoinTable的
     * name中间表表名: BOOK_AUTHOR_MAPPING
     * joinColumnName中间表指向当前实体的外键的列名: BOOK_ID
     * inverseJoinColumnName中间表指向关联实体的外键的列名: AUTHOR_ID
     * 一个角色可以关联多个权限
     *
     * @return
     */
    @ManyToMany
    @JoinTable(
            name = "ST_ROLE_PERMISSION",
            joinColumnName = "ROLE_ID",
            inverseJoinColumnName = "PERMISSION_ID"
    )
    List<StPermission> permissions();

    /**
     * 一个角色可以关联多个用户
     *
     * @return
     */
    @ManyToMany(mappedBy = "roles")
    List<StUser> users();
}